package han.cirno.corrupt.util

import okhttp3.Response

fun Int.fit(intRange: IntRange):Int{
    if (this<intRange.first)return intRange.first
    if (this>intRange.last)return intRange.last
    return this
}

fun Response.getBodyStringAndClose():String?{
    return use { (it.body?:return null).string() }
}

fun <T> chain(vararg t: T?):T?= t.find { it!=null }